#!/bin/bash -xe

mkdir -p code
cd code

# 下载linux kernel 5.8
if [ ! -e linux_kernel ]; then
    wget -c http://mirrors.163.com/kernel/v5.x/linux-5.8.tar.xz
    tar axf linux-5.8.tar.xz
    mv linux-5.8 linux_kernel
    rm -rf linux-5.8.tar.xz
fi

# 下载busybox
if [ ! -e busybox ]; then
    git clone --depth=1 https://gitee.com/mirrors/busyboxsource
    if [ "$?" != "0" ]; then
        rm -rf busyboxsource
    fi
    mv busyboxsource busybox
fi

if [ ! -e bash ]; then
    wget -c https://mirrors.aliyun.com/gnu/bash/bash-5.1.tar.gz
    tar axf bash-5.1.tar.gz
    mv bash-5.1 bash
    rm -rf bash-5.1.tar.gz
fi
